home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / Asm / Blitter / DrawRGBPixel.s < prev    next >
Encoding:
Text File  |  1998-03-16  |  3.3 KB  |  145 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Draws a pixel on a screen without destroying the background.  This
  3. ;version demonstrates an easy way of supporting all the different screen
  4. ;types (true colour, chunky, planar...) by drawing with RGB values.
  5.  
  6.     INCDIR    "GMSDev:Includes/"
  7.     INCLUDE    "dpkernel/dpkernel.i"
  8.  
  9.     SECTION    "DrawPixel",CODE
  10.  
  11. ;===========================================================================;
  12. ;                             INITIALISE DEMO
  13. ;===========================================================================;
  14.  
  15.     STARTDPK
  16.  
  17. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  18.     move.l    DPKBase(pc),a6
  19.     lea    FILE_Background(pc),a0    ;Load the picture.
  20.     moveq    #ID_PICTURE,d0
  21.     CALL    Load
  22.     move.l    d0,PIC_Background
  23.     beq.s    .Exit
  24.  
  25.     moveq    #ID_SCREEN,d0
  26.     CALL    Get
  27.     move.l    d0,Screen
  28.     beq.s    .Exit
  29.  
  30.     move.l    PIC_Background(pc),a0
  31.     move.l    Screen(pc),a1
  32.     CALL    CopyStructure
  33.  
  34.     move.l    Screen(pc),a0
  35.     sub.l    a1,a1
  36.     CALL    Init
  37.     tst.l    d0
  38.     beq.s    .Exit
  39.  
  40.     move.l    PIC_Background(pc),a0
  41.     move.l    PIC_Bitmap(a0),a0
  42.     move.l    Screen(pc),a1
  43.     move.l    GS_Bitmap(a1),a1
  44.     CALL    Copy
  45.  
  46.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  47.     CALL    Get
  48.     move.l    d0,JoyData
  49.     beq.s    .Exit
  50.     move.l    d0,a0    ;Initialise the joydata structure.
  51.     sub.l    a1,a1
  52.     CALL    Init
  53.     tst.l    d0
  54.     beq.s    .Exit
  55.  
  56.     move.l    Screen(pc),a0
  57.     CALL    Display
  58.  
  59.     bsr.s    Main
  60.  
  61. .Exit    move.l    DPKBase(pc),a6
  62.     move.l    JoyData(pc),a0
  63.     CALL    Free
  64.     move.l    Screen(pc),a0
  65.     CALL    Free
  66.     move.l    PIC_Background(pc),a0
  67.     CALL    Free
  68.     MOVEM.L    (SP)+,A0-A6/D1-D7
  69.     moveq    #ERR_OK,d0
  70.     rts
  71.  
  72. ;===========================================================================;
  73. ;                                MAIN LOOP
  74. ;===========================================================================;
  75.  
  76. Main:    moveq    #100,d6
  77.     moveq    #100,d7
  78. .loop    move.l    BLTBase(pc),a6
  79.  
  80.     ;Replace the background pixel.
  81.  
  82.     move.l    Screen(pc),a0
  83.     move.l    GS_Bitmap(a0),a0
  84.     movem.w    OldPixel(pc),d1/d2
  85.     move.l    OldColour(pc),d3
  86.     blt.s    .read
  87.     CALL    bltDrawRGBPixel    ;>> = Draw the old background pixel.
  88.  
  89.     ;Read the new background pixel.
  90.  
  91. .read    move.l    Screen(pc),a0
  92.     move.l    GS_Bitmap(a0),a0
  93.     move.w    d6,d1    ;d1 = X Coordinate.
  94.     move.w    d7,d2    ;d2 = Y Coordinate.
  95.     CALL    bltReadRGBPixel    ;>> = Read the pixel.
  96.     movem.w    d6/d7,OldPixel    ;MA = Save coords of next pixel.
  97.     move.l    d0,OldColour    ;MA = Save colour of next pixel.
  98.  
  99.     ;Draw the pixel.
  100.  
  101.     move.l    Screen(pc),a0
  102.     move.l    GS_Bitmap(a0),a0
  103.     move.w    d6,d1    ;d1 = X Coordinate.
  104.     move.w    d7,d2    ;d2 = Y Coordinate.
  105.     move.l    #$aaaaaa,d3    ;d3 = Colour.
  106.     CALL    bltDrawRGBPixel    ;>> = Draw our pixel.
  107.  
  108.     move.l    SCRBase(pc),a6
  109.     CALL    scrWaitAVBL    ;>> = Wait for VBL.
  110.  
  111.     move.l    DPKBase(pc),a6
  112.     move.l    JoyData(pc),a0
  113.     CALL    Query
  114.     move.l    JoyData(pc),a0
  115.     add.w    JD_YChange(a0),d7
  116.     add.w    JD_XChange(a0),d6
  117.     move.l    JD_Buttons(a0),d0
  118.     btst    #JB_LMB,d0
  119.     beq.s    .loop
  120.     rts
  121.  
  122. OldPixel:
  123.     dc.w    0,0
  124. OldColour:
  125.     dc.l    -1
  126.  
  127. ;===========================================================================;
  128. ;                                  DATA
  129. ;===========================================================================;
  130.  
  131. JoyData:     dc.l  0
  132. Screen:         dc.l  0
  133. PIC_Background:     dc.l  0
  134. FILE_Background: FILENAME "GMS:demos/data/PIC.Green"
  135.  
  136. ;===========================================================================;
  137.  
  138. ProgName:    dc.b  "Draw RGB Pixel",0
  139. ProgAuthor:    dc.b  "Paul Manias",0
  140. ProgDate:    dc.b  "January 1998",0
  141. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1998.  Freely distributable.",0
  142. ProgShort:    dc.b  "Pixel demonstration.",0
  143.         even
  144.  
  145.